<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class PasswordDTO extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'password' => 'required|between:6,18',
            'newpwd' => 'required|between:6,18|confirmed',
            'newpwd_confirmation' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'password.required' => '原密码不能为空',
            'password.between' => '原密码长度不符合规则',
            'newpwd.required' => '新密码不能为空',
            'newpwd.between' => '新密码长度不符合规则',
            'newpwd.confirmed' => '两次密码不一致',
            'newpwd_confirmation.required' => '确认密码不能为空',
        ];
    }
}
